<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const obj = {
        // 普通函数中，谁调用，this就指向谁
        sayHello() {
          console.log('sayHello -----> ', this);
        },
        // 箭头函数，不会创建自己的this，它只会从自己的作用域链的上一层继承 this
        sayHi: () => {
          console.log('sayHi -----> ', this);
        },
      };

      obj.sayHello(); //  this指向哪里？ --- obj
      obj.sayHi(); //  this指向哪里？ --- window
    </script>
  </body>
</html>
